import isWebp from "./isWebp.js";

// is isWebp
function isWebpTest(){
    const value = new Uint8Array([32,54,0,0,0,0,0,0,87,69,66,80,0,0]);

    let result;
    let startTime = Date.now();
    for (let i = 0; i < 1000000; i++) {
        result = isWebp(value)
    }
    let endTime = Date.now();

    if(result !== true){
        throw new Error('is-isWebp-master_isWebp_0100 Error')
    }

    print(`is-isWebp-master_isWebp_0100: ${endTime - startTime} ms`)
    
    // if(isWebp(value)){
    //     print('The file is in Webp format');
    // }else{
    //     print('The file is not in Webp format')
    // }
}


// not is Webp
function isNotTest(){
    const value = new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0]);

    let result;
    let startTime = Date.now();
    for (let i = 0; i < 1000000; i++) {
        result = isWebp(value)
    }
    let endTime = Date.now();

    if(result !== false){
        throw new Error('is-Webp-master_isWebp_0200 Error')
    }

    print(`is-Webp-master_isWebp_0200: ${endTime - startTime} ms`)
    
    // if(isWebp(value)){
    //     print('The file is in Webp format');
    // }else{
    //     print('The file is not in Webp format')
    // }
}

function Switch() {
    isWebpTest()
    isNotTest()
}
Switch()
